// 获取展示的按钮
$(function () {
    //获取到所有的按钮
    var $actives = $(".zhanshi-active > li");
    // 获取到jquery对象的长度
    var length = $actives.length
    // 获取到所有需要展示的divs
    var $divs = $(".zhanshi");
    // 获取箭头
    var $jiantouz = $(".c-jiantouz");
    // console.log(jiantouz);
    var $jiantouy = $(".c-jiantouy");
    // console.log(jiantouy);
    // console.log($divs);
    // 定义变量
    var targetIndex = 0;
    var index;
    // console.log(length);
    for (let i = 0; i < length; i++) {
        $actives[i].onclick = function () {
            $actives[i].setAttribute("class", "active");
            $actives[targetIndex].removeAttribute("class");


            $divs[i].classList.add("show");
            $divs[targetIndex].classList.remove("show");
            targetIndex = i;
            console.log(targetIndex);
        }
    }
    // 绑定事件监听
    $jiantouz.on('click', function () {
       targetIndex--;
       index = targetIndex;
       if(targetIndex < 0) {
           targetIndex = 4;
       }
       $actives[targetIndex].setAttribute("class", "active");
       $actives[index+1].removeAttribute("class");
       $divs[targetIndex].classList.add("show");
       $divs[index+1].classList.remove("show");
    });
    $jiantouy.on('click', function () {
        targetIndex++
        index = targetIndex
        if(targetIndex===5){
            targetIndex = 0;
        }
        console.log(targetIndex + '');
        console.log(index);
        $actives[targetIndex].setAttribute("class", "active");
        $actives[index-1].removeAttribute("class");

        $divs[targetIndex].classList.add("show");
        $divs[index - 1].classList.remove("show");

    })

})